const express=require('express')
const router= express.Router();
const db=require('../../utils/db')

// 查询历史订单
router.get('/gethistoryorder',function(req,res){
    let mysql=`SELECT order_id,order_num,customer_name,order_time,customer_type,cash_money,pay_way,table_num,order_state FROM order_information 
               JOIN customer ON order_information.order_username=customer.customer_id
               JOIN pay_method ON order_information.order_pay_way=pay_method.pay_id
               JOIN cash_flowing ON order_information.order_id=cash_flowing.cash_num
               JOIN table_area ON cash_flowing.cash_table_area=table_area.table_id`
    db(mysql,null,function(err,data){
        console.log(err);
        if(err){
            return res.json({
                code: 500,
                msg: '查询历史订单失败，请稍后重试'
            })
        }
        res.json({
            code: 200,
            msg: '查询历史订单成功',
            data: data
        })
    })
})


module.exports = router